//
//  TiDanDetailCarCell.m
//  LogisticsSupplier
//
//  Created by 吕晶 on 2020/9/15.
//  Copyright © 2020 吕晶. All rights reserved.
//

#import "TiDanDetailCarCell.h"

@interface TiDanDetailCarCell ()

@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UILabel *numLab;
@property (nonatomic, strong) UILabel *driverLab;
@property (nonatomic, strong) UIButton *modifyBtn;

@end

@implementation TiDanDetailCarCell

+ (instancetype)TiDanDetailCarCellWithTableView:(UITableView *)tableView {
    static NSString *cellID = @"TiDanDetailCarCell";
    TiDanDetailCarCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[TiDanDetailCarCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = Color_backgroundColor;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.bgView = [[UIView alloc] initWithFrame:CGRectMake(15, 10, ScreenW - 30, 72)];
        self.bgView.backgroundColor = HexColor(0xffffff);
        self.bgView.layer.masksToBounds = YES;
        self.bgView.layer.cornerRadius = 6;
        [self.contentView addSubview:self.bgView];
        
        self.numLab = [[UILabel alloc] initWithFrame:CGRectMake(15, (72 - 35) * 0.5, ScreenW - 30 - 30 - 96 - 10, 17)];
        self.numLab.font = BoldFontOfSize(16);
        self.numLab.textColor = HexColor(0x2B2C44);
        [self.bgView addSubview:self.numLab];
        
        self.driverLab = [[UILabel alloc] initWithFrame:CGRectMake(15, self.numLab.nim_bottom + 3, ScreenW - 30 - 30 - 96 - 10, 15)];
        self.driverLab.font = [UIFont systemFontOfSize:14];
        self.driverLab.textColor = HexColor(0x585974);
        [self.bgView addSubview:self.driverLab];
        
        self.modifyBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.bgView.nim_width - 15 - 96, (self.bgView.nim_height - 36) * 0.5, 96, 36)];
        self.modifyBtn.backgroundColor = HexColorA(0xFBA962, 0.1);
        [self.modifyBtn setTitleColor:HexColor(0xFBA962) forState:0];
        self.modifyBtn.titleLabel.font = BoldFontOfSize(14);
        [self.modifyBtn setTitle:@"修改车辆" forState:0];
        [self.modifyBtn addTarget:self action:@selector(modifyClick) forControlEvents:UIControlEventTouchUpInside];
        self.modifyBtn.layer.masksToBounds = YES;
        self.modifyBtn.layer.cornerRadius = 18;
        [self.bgView addSubview:self.modifyBtn];
        
        self.height = self.bgView.nim_bottom;
    }
    return self;
}

- (void)modifyClick {
    if (self.modifyBlock) {
        self.modifyBlock();
    }
}

-(void)setCarNum:(NSString *)carNum {
    _carNum = carNum;
    self.numLab.text = [NSString stringWithFormat:@"调度车辆：%@",carNum];
}

-(void)setDriver:(NSString *)driver {
    _driver = driver;
    self.driverLab.text = [NSString stringWithFormat:@"司机：%@",driver];
}

-(void)setCanModify:(BOOL)canModify {
    _canModify = canModify;
    self.modifyBtn.hidden = !canModify;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
